<!--移动签批->公文详情->司局收文->index-->
<template>
  <view>
    <van-tabs color="#1989fa" title-active-color="#1989fa" animated swipeable @change="onChange">
      <van-tab title="公文详情" name="gwxq">
        <detail ref="detail" :proInstId="proInstId" :detailObj1="detailObj1" :otherDetail="otherDetail"
                @showCirculate="showCirculate" @showFenfaSheet="showFenfaSheet"></detail>
      </van-tab>
      <van-tab title="版式稿纸" name="bsgz">
        <read :detailObj1="detailObj1" :proInstId="proInstId" :otherDetail="otherDetail"></read>
      </van-tab>
      <van-tab title="流转过程" name="lzgc" :key='2'>
        <docProcess :dataList="dataList"></docProcess>
      </van-tab>
    </van-tabs>
    <edit ref="edit" @refreshBtnGroup="refreshBtnGroup" :showEdit="showEdit" @closeEdit="closeEdit"></edit>
    <records @refreshBtnGroup="refreshBtnGroup" :showRecords="showRecords" @closeRecords="closeRecords"
             :paramObject="paramObject"  @tuiSms="getSms"></records>
    <trans ref="trans" :proInstId="proInstId" @refreshBtnGroup="refreshBtnGroup" :showTrans="showTrans"
           @closeTrans="closeTrans" :paramObject="paramObject" :detailObject="detailObj1.detailObj"></trans>
    <circulate ref="circulate" :showCircu="showCircu" :proInstId="proInstId" :title="circuTitle"
               @closeCirculate="closeCirculate"></circulate>
    <cy ref="cy" @refreshBtnGroup="refreshBtnGroup" :showCy="showCy" @closeCy="closeCy" :paramObject="paramObject"
        :gwTitle="circuTitle"></cy>
    <fb ref="fb" @refreshBtnGroup="refreshBtnGroup" :showFb="showFb" @closeFb="closeFb" :paramObject="paramObject"
        :gwTitle="circuTitle"></fb>

    <more :showShare="showShare" @closeShare="closeShare" :options="barList.slice(4)"></more>
    <fenfa ref="fenfa" :showFenfa="showFenfa"  @closeFenfaSheet="closeFenfaSheet"></fenfa>
    <div style="height: 5rem;" v-if="fromType != 'search'">
      <van-tabbar v-model="active">
        <!-- <van-tabbar-item v-for="(item,index) in barList" v-if="index < 4" :name="item.name" :icon="item.icon" @click="onClick(item.name)">{{item.value}}
        </van-tabbar-item> -->
        <van-tabbar-item v-for="(item,index) in barList" :key="index" v-if="index < 4" :name="item.name"
                         @click="onClick(item.operation)">
          <span>{{ item.value }}</span>
          <template #icon="props">
            <img :src="props.active ? item.iconTab.active : item.iconTab.inactive"/>
          </template>
        </van-tabbar-item>
      </van-tabbar>
    </div>
  </view>
</template>

<script>
import detail from 'pages/caac/components/sjswDoc/compo-detail';
import docProcess from 'pages/caac/components/sjswDoc/compo-process';
import read from 'pages/caac/components/sjswDoc/compo-read';
import edit from 'pages/caac/components/sjswDoc/compo-edit';
import records from 'pages/caac/components/common/compo-records';
import trans from 'pages/caac/components/sjswDoc/compo-trans';
import more from 'pages/caac/components/sjswDoc/compo-more';
import circulate from 'pages/caac/components/common/compo-circulate';
import cy from 'pages/caac/components/common/compo-cy';
import fb from 'pages/caac/components/common/compo-fbgl';
import fenfa from 'pages/caac/components/common/compo-fenfa';
export default {
  components: {
    detail,
    docProcess,
    edit,
    records,
    trans,
    more,
    read,
    circulate,
    cy,
    fb,
    fenfa
  },
  onLoad: async function (option) {
    await this.$onLaunched //解決bug：执行完onLaunch后再执行页面onLoad
    this.userInfo = this.cache.get('userInfo')//从缓存获取用户信息
    //从地址栏获取proInstId
    this.proInstId = option.proInstId
    // console.log(proInstId);
    //fromType==search，说明是从公文搜索页跳转过来，隐藏相关操作按钮
    this.fromType = option.from
    if (this.proInstId != undefined && this.proInstId != '') {
      this.getCaacDetail(this.proInstId)//通过proInstId获取详情
      this.quertcirs(this.proInstId)//传阅情况
      this.findfbdept(this.proInstId)//分办处室
      this.getfasongdepts(this.proInstId)//已发送部门
      this.getCaacOpinion(this.proInstId)//获取意见
    }
  },
  created() {

  },
  //文件编辑保存后返回到首页就重新获取文件及附件
  onShow(){
    //延迟调用，防止文件过大PC端没保存上就获取
    setTimeout(() => {
      if(this.util.isNotEmpty(this.extendIdForRelate)){
        this.getCaacBody(this.extendIdForRelate)//获取正文
        this.getCaacAttachment(this.extendIdForRelate)//获取附件
        this.getRelation(this.extendIdForRelate)//获取附加公文
      }
    }, 800)
  },
  data() {
    return {
      fromType: '',//fromType==search，说明是从公文搜索页跳转过来，隐藏相关操作按钮
      //记录对应的tab页数据是否已加载
      gwxqFlag: true,
      bsgzFlag: true,
      lzgcFlag: true,
      extendIdForRelate: '',
      gwSercetSms: {},//公文秘书，调退公文秘书接口用参数
      gwSercetJms: {},//公文秘书-局秘书，调退公文秘书接口用参数
      userInfo: {},//当前登录用户信息，目前先从缓存中获取
      proInstId: '',
      tuiGongWen: [],//退公文秘书所需参数，调用listNextActivities接口获得
      endGongWen: [],//结束公文所需参数，调用listNextActivities接口获得
      fwId: '',//发文id
      active: '',
      showEdit: false,
      showRecords: false,
      showTrans: false,
      showShare: false,
      barList: [],
      //公文详情
      detailObj1: {
        detailObj: null,//详情
        detailBody: null,//正文
        detailAttachment: null,//附件
        opinion: null,//意见
        optionBtn01: null,//获取签批功能菜单所需要的参数
        optionBtn02: null,//获取签批功能菜单所需要的参数
        optionBtn: null,//签批功能菜单,根据optionBtn01和optionBtn02返回的参数作为请求参数
      },
      dataList: {
        docProcess: {}, // 流转过程
        signProcess: [],// 会签件
        quertcirsProcess:[],//传阅人员
      },
      docProcess: [],//流转过程
      options: [],//更多操作
      //获取签批功能的接口里有
      paramObject: {
        //"bizId":"c7cbc671330d472b94fac967ba7b3840","proInstId":"55d46548585546c9a667796abf640713","configId":"68f6c3cf43aa466f899798691229159b","proDirId":"25ded9cc79b94329beffa78225a077c9","actInstId":"9af5da0ced204e36af9da9cd909394d5","actDefId":"nigao","workitemId":"5de39682f91d423b99b9a3f3e041d4e0","state":null,"isClosed":"2","configCode":"mhj_fw"
      },
      generateParamObject: {
        "fwId": '',
        "fwWord": '',
        "fwWordId": ''
      },
      buttonArr: [],    // 要显示的功能按钮
      showCircu: false,   // 传阅详情
      circuTitle: '',     // 标题
      showCy: false,      // 传阅按钮
      showFb: false,      // 分办按钮
      otherDetail: {
        fbDeptList: [],// 已分办处室
        chuanYueList: [],//传阅情况
        fsDeptList: [],//已发送部门
      },
      showFenfa: false,//分发组件
      opinionId:'',//需要删除的意见ID
    };
  },
  watch: {},

  mounted() {
    //处理页面弹出层初始化
    this.active = 'gwxq'
    this.showEdit = false
    this.showRecords = false
    this.showTrans = false
    this.showShare = false
    //延迟调用listNextActivities获取下一活动节点信息，
    setTimeout(() => {
      this.listNextActivities()
    }, 2000)
  },
  methods: {
    //显示分发组件
    showFenfaSheet(){
      this.showFenfa = true
    },
    //关闭分发组件
    closeFenfaSheet(userInfo){
      //userInfo: {"userId":["2163","8943"],"userName":["刘xx","刘xx"]}
      this.$refs.detail.initParam(userInfo)
      this.showFenfa = false
    },
    //tab 点击事件
    onChange(itemTitle) {
      // this.$toast(itemTitle)
      if (itemTitle == 'gwxq') {//公文详情
        if (this.gwxqFlag) {
          this.getCaacDetail(this.proInstId)
        }
      } else if (itemTitle == 'bsgz') {//版式稿纸
        if (this.bsgzFlag) {
          //TODO 加载版式稿纸
        }
      } else if (itemTitle == 'lzgc') {//流转过程
        if (this.lzgcFlag) {
          this.getCaacDocProcess(this.proInstId)
          this.getListChildSubOperationLogs(this.proInstId)
        }
      }
    },
    //关闭修改公文要素
    closeEdit(showEdit) {
      this.showEdit = false
    },
    //关闭填写意见
    closeRecords(showRecords) {
      this.showRecords = false
    },
    //关闭流转
    closeTrans(showTrans) {
      this.showTrans = false
    },
    //关闭更多操作
    closeShare(item) {
      this.showShare = false
      this.btnFunction(item)
    },

    //点击tabbar
    onClick(item) {
      this.btnFunction(item)
    },
    //下边菜单点击功能
    btnFunction(item) {
      //修改公文要素
      if (item == 'xggwys' || item == 'swys') {
        this.showEdit = true
        this.$refs.edit.editGw(this.proInstId);//调用子组件的方法
      }
      //填写意见
      if (item == 'addReviews') {
        this.showRecords = true
      }
      //流转
      if (item == 'generalMove' || item == 'complete') {
        this.showTrans = true
        //调用子组件的方法
        this.$refs.trans.getSelectPerson(this.proInstId, this.detailObj1.detailObj.drafterId)
      }
      //传阅
      if (item == 'circulate') {
        this.showCy = true
        this.circuTitle = this.detailObj1.detailObj.title
      }
      //分办管理
      if (item == 'fensongManagement') {
        this.showFb = true
        this.circuTitle = this.detailObj1.detailObj.title
      }
      //更多操作
      if (item == 'more') {

        this.showShare = true
      }
      //结束公文
      if (item == 'js' || item == 'endProcess') {
        this.endProcess()
      }
      //会签管理
      if (item == 'huiqianManagement') {
        //跳转到会签页面
        uni.navigateTo({
          url: "/pages/caac/submit/countersign?proInstId=" + this.proInstId + "&fwId=" + this.extendIdForRelate
        })
      }
      //办结并退秘书--走公文结束流程
      if (item == 'goOutProInst') {
        this.endAndTuimsConfirm()
      }
      //退处室秘书
      if (item == 'tuisms' || item=='tuichushiMs') {
        this.tuiGwmsConfirm('tuisms')
      }
      //退局秘书
      if (item == 'tgwms') {
        this.tuiGwmsConfirm('tgwms')
      }
      //作废
      if (item == 'cancelGw' || item == 'zuofei') {
        this.cancelGwConfirm()
      }
      if (item == 'jldyy' ) {
        this.opinionType('ldps')//已阅
      }
      if (item == 'jmsyy' || item == 'readalready') {
        this.opinionType('sjsw_blbmyj')//已阅
      }
      //本单位会签完毕hqwb
      if (item == 'hqwb') {
        this.hqwbConfirm()
      }
      //清除意见
      if (item == 'deleteOpinion') {
        this.deleteOpinionConfirm()
      }
    },

    // 获取要显示的按钮
    async getButtonsData(proInstId) {
      await this.$http({
        url: this.$http.adornUrl(`/caac/oa/app/getButtonsData`),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          'proInstId': proInstId
        })
      }).then(({data}) => {
        if (data.code == 200) {
          this.buttonArr = data.data.buttons
        }
      })
    },

    // 关闭分办窗口
    closeFb() {
      this.showFb = false
    },
    // 关闭传阅窗口
    closeCy() {
      this.showCy = false
    },
    // 显示传阅详情
    showCirculate(val) {
      this.showCircu = true
      this.circuTitle = this.detailObj1.detailObj.title
      this.$refs.circulate.getCirculate(this.proInstId)
    },
    // 关闭传阅详情
    closeCirculate(val) {
      this.showCircu = false
    },

    //同意或已阅1-同意，2-已阅
    opinionType(opinionType) {
      this.$dialog.confirm({
        title: '系统提示',
        message: '确定要操作吗?',
      }).then(() => {
        if (this.util.isNotEmpty(this.paramObject)) {
            this.message = '已阅'
            this.opiniontype = opinionType
            this.saveopinion()
        }
      }).catch(() => {
        // on cancel
      });
    },
    //填写意见接口
    saveopinion() {
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/component/approval/saveopinion`),
        method: 'post',
        params:{
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
        },
        data: this.$http.adornData({
          'proInstId': this.paramObject.proInstId,//发文详情返回的proInstId
          'workItemId': this.paramObject.workitemId,//
          'actInstId': this.paramObject.actInstId,//
          'opiniontype': this.opiniontype,
          'opinion': this.message,
          'isApproval': '1',//核稿状态，默认传1
        })
      }).then(({data}) => {
        if (data.code == 200) {
          this.$toast('意见填写成功')
          this.refreshBtnGroup(true)
        } else {
          this.$toast(data.message + ' code:' + data.code)
        }
      })
    },
    //作废
    cancelGwConfirm() {
      this.$dialog.confirm({
        title: '系统提示',
        message: '您确定要操作吗?',
      }).then(() => {
        // on confirm
        this.cancelGw()

      }).catch(() => {
        // on cancel
      });
    },
    //作废公文
    cancelGw() {
      this.$httploading({
        url: this.$http.adornUrl(`/caac/oa/component/workflow/abortApplictionController/abortApplication`),
        method: 'post',
        params: {
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          data: this.$http.adornData({
            'configId': this.paramObject.configId,
            'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
            'proInstId': this.paramObject.proInstId,
            'actInstId': this.paramObject.actInstId,//
            'workitemId': this.paramObject.workitemId,
            'gwId': this.fwId,
            'title': this.detailObj1.detailObj.title
          }),
        }
      }).then(({data}) => {
        if (data.code == 200) {
          this.$toast("操作成功")
          //作废后还需调另外两个接口
          this.canceGwUpdateDraftStatus()
          this.canceGwDeleteWordBiz()
          uni.redirectTo({
            url: '/pages/caac/send/signList'
          })
        } else {
          this.$toast(data.message + ' code:' + data.code)
        }
      })
    },
    //作废-更新状态
    canceGwUpdateDraftStatus() {
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/doc/fw/updateDraftStatus`),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          'id': this.proInstId
        })
      }).then(({data}) => {
        //data: {"code":200,"data":{"userId":"3961"},"message":null}
        console.log("作废UpdateDraftStatus()--->data: " + JSON.stringify(data));
      })

    },
    //作废-更新状态
    canceGwDeleteWordBiz() {
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/doc/fw/deleteWordBiz`),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          'fwId': this.fwId
        })
      }).then(({data}) => {
        //data: {"code":200,"data":{"userId":"3961"},"message":null}
        console.log("作废DeleteWordBiz()-->data: " + JSON.stringify(data));
      })

    },
    //本单位会签完毕
    hqwbConfirm() {
      this.$dialog.confirm({
        title: '系统提示',
        message: '您确定要操作吗?',
      }).then(() => {
        this.jieshuGongWen()//本单位会签完毕和结束公文是同一个接口
      }).catch(() => {
        // on cancel
      });
    },
    //结束公文确认弹框
    endProcess() {
      this.$dialog.confirm({
        confirmButtonColor: '#1989fa',
        title: '系统提示',
        message: '确认要结束公文吗?',
      }).then(() => {
        this.jieshuGongWen()//结束公文
      }).catch(() => {
        // on cancel
      });
    },
    //获取发电待办详情数据
    getCaacDetail(proInstId) {
      this.$httploading({
        url: this.$http.adornUrl(`/caac/oa/doc/sjsw/sjswproInstId/` + proInstId),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        console.log("公文详情: " + JSON.stringify(data));
        if (data.code == 200) {
          //根据字典code获取字典
          this.detailObj1.detailObj = data.data
          this.generateParamObject.fwId = data.data.fwId
          this.generateParamObject.fwWord = data.data.fwWord
          this.generateParamObject.fwWordId = data.data.fwWordId
          this.fwId = data.data.fwId
          this.extendIdForRelate = data.data.extendIdForRelate
          this.getCaacBody(this.extendIdForRelate)//获取正文
          this.getCaacAttachment(this.extendIdForRelate)//获取附件
          this.getRelation(this.extendIdForRelate)//获取附加公文
          this.openwfneededdata(this.fwId, proInstId)
          this.gwxqFlag = false //请求成功后置为false，防止tab切换重新获取数据
        }

      })
    },

    //获取正文数据
    getCaacBody(extendIdForRelate) {
      this.$httploading({
        url: this.$http.adornUrl(`/caac/oa/component/attachmentupload/attachmentinfoOrderByNew`),
        method: 'get',
        params: this.$http.adornParams({
          'bizId': extendIdForRelate,
          'attachTypeId': 'pageBody_mainText',
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          this.detailObj1.detailBody = data.data
        }
      })
    },

    //获取附件数据
    getCaacAttachment(extendIdForRelate) {
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/component/attachmentupload/attachmentinfoOrderByNew`),
        method: 'get',
        params: this.$http.adornParams({
          'bizId': extendIdForRelate,
          'attachTypeId': 'pageBody_uploadFile',
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          this.detailObj1.detailAttachment = data.data
        }
      })
    },

    //获取意见
    getCaacOpinion(proInstId) {
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/component/approval/approvalwrite`),
        method: 'get',
        params: this.$http.adornParams({
          'proInstId': proInstId,
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          if (data.data != null) {
            this.detailObj1.opinion = data.data
          }
        }
      })
    },
    //获取附加公文
    getRelation(extendIdForRelate) {
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/mhjComponent/relationfile/relation`),
        method: 'get',
        params: this.$http.adornParams({
          'docId': extendIdForRelate,
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        //[{"id":"1c0962f8839d46f792f84e5c89c96f14","title":"ppap","relateDocId":"4ec205b8334446f9b932d0fcb3896bc8","proInstId":"4ec205b8334446f9b932d0fcb3896bc8"},{"id":"2f4aa437ecba4c748bff911f03667147","title":"py","relateDocId":"86d30c881c494b468534685bb0746174","proInstId":"86d30c881c494b468534685bb0746174"}]
        if (data.code == 200) {
          if (data.data != null) {
            this.detailObj1.relation = data.data
          }
        }
      })
    },
    //获取流转过程
    getCaacDocProcess(proInstId) {
      this.$httploading({
        url: this.$http.adornUrl(`/caac/oa/component/workflow/workflowController/listProInstIdOperationLogs`),
        method: 'post',
        params: this.$http.adornParams({
          'proInstId': proInstId,
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          this.dataList.docProcess = data.data
          this.lzgcFlag = false
        }
      })
    },
    //获取子流转过程
    getListChildSubOperationLogs(proInstId) {
      this.$httploading({
        url: this.$http.adornUrl(`/caac/oa/component/workflow/workflowController/listChildSubOperationLogs?systemKey=` + this.userInfo.systemKey + `&systemFlag=` + this.userInfo.systemFlag),
        method: 'post',
        params: this.$http.adornParams({
          'proInstId': proInstId,
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          this.dataList.signProcess = data.data
        }

      })
    },

    //获取签批功能菜单optionBtn01
    openwfneededdata(fwId, proInstId) {
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/comm/comm/openwfneededdata`),
        method: 'get',
        params: this.$http.adornParams({
          'id': fwId,//发文详情返回的fwId
          'proInstId': proInstId,//发文详情返回的proInstId
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          this.detailObj1.optionBtn01 = data.data
          this.paramObject = data.data
          this.getRoleTypesAndActInst(data.data.configId, proInstId)
        }

      })
    },

    //获取签批功能菜单optionBtn02
    getRoleTypesAndActInst(configId, proInstId) {
      var _this = this
      this.$http({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/getRoleTypesAndActInst`),
        method: 'post',
        params: this.$http.adornParams({
          'proInstId': proInstId,//发文详情返回的proInstId
          'configId': configId,//openwfneededdata()返回的configId
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag//固定值
        })
      }).then(({data}) => {
        if (data.code == 200) {
          _this.detailObj1.optionBtn02 = data.data
          console.log("签批功能菜单optionBtn02: " + JSON.stringify(data.data));
          _this.initActivity()

        }

      })
    },

    /**
     * 子页面流转后调用此方法刷新功能按钮
     * @param {Object} item Boolean值，为true 就刷新
     */
    refreshBtnGroup(item) {
      // console.log("shuaxina "+item)
      this.getCaacDetail(this.proInstId)
      this.getCaacOpinion(this.proInstId)//重新获取意见
      this.quertcirs(this.proInstId)//传阅情况
      this.getfasongdepts(this.proInstId)//已发送部门
      setTimeout(()=>{
        this.findfbdept(this.proInstId)//司局分办处室
      }, 500)
    },
    //获取签批功能菜单
    async initActivity() {
      // 获取要显示的按钮
      await this.getButtonsData(this.proInstId)
      const _this = this
      let option01 = this.detailObj1.optionBtn01
      let option02 = this.detailObj1.optionBtn02.actInstList[0] //TODO 次处返回了数组格式，需和pc端确认
      // console.log("option02===: " + JSON.stringify(option02));
      await this.$http({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/initActivity`),
        method: 'post',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          'data': this.$http.adornData({
            'configId': option01.configId,//openwfneededdata()返回的configId
            'configCode': option01.configCode,
            'proDirId': option01.proDirId,
            'actDefId': option01.actDefId,
            'wfmRoleTypes': option02.wfmRoleTypes,
            'proInstId': option01.proInstId,
            'actInstId': option01.actInstId,
            'workitemId': option01.workitemId,
            'wfmInitPageType': 'running',
            'bizId': option01.bizId
          }),

        })
      }).then(({data}) => {
        console.log("data---->>: " + JSON.stringify(data));
        if (data.code == 200) {
          _this.detailObj1.optionBtn = data.data
          var operations = data.data.qualifiedOperations
          // console.log(operations);
          _this.barList = [] //重置为空
          if (operations != null && operations.length > 0) {
            //TODO 还需判断其他类型的按钮
            for (let i = 0; i < operations.length; i++) {
              //修改公文要素
              if (operations[i].operation == 'swys') {
                _this.barList.push({
                  name: '修改公文要素',
                  operation: 'swys',
                  icon: 'static/imgs/icon/icon-xggwys.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-xggwys-active.png',
                    inactive: 'static/imgs/icon/icon-xggwys.png'
                  },
                  value: operations[i].operationName,
                  sort: 10
                })
              }
              //修改公文要素
              if (operations[i].operation == 'xggwys') {
                _this.barList.push({
                  name: '修改公文要素',
                  operation: 'xggwys',
                  icon: 'static/imgs/icon/icon-xggwys.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-xggwys-active.png',
                    inactive: 'static/imgs/icon/icon-xggwys.png'
                  },
                  value: operations[i].operationName,
                  sort: 10
                })
              }
              //填写意见
              if (operations[i].operation == 'addReviews') {
                _this.barList.push({
                  name: '填写意见',
                  operation: 'addReviews',
                  icon: 'static/imgs/icon/icon-opinion.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-opinion-active.png',
                    inactive: 'static/imgs/icon/icon-opinion.png'
                  },
                  value: operations[i].operationName,
                  sort: 1
                })
              }
              //流转
              if (operations[i].operation == 'generalMove') {
                _this.barList.push({
                  name: '流转',
                  operation: 'generalMove',
                  icon: 'static/imgs/icon/icon-transfer.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-transfer-active.png',
                    inactive: 'static/imgs/icon/icon-transfer.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }
              //流转
              if (operations[i].operation == 'complete') {
                _this.barList.push({
                  name: '流转',
                  operation: 'complete',
                  icon: 'static/imgs/icon/icon-transfer.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-transfer-active.png',
                    inactive: 'static/imgs/icon/icon-transfer.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }
              //结束公文
              if (operations[i].operation == 'js') {
                _this.barList.push({
                  name: '结束公文',
                  operation: 'js',
                  icon: 'static/imgs/icon/icon-finished.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-finished-active.png',
                    inactive: 'static/imgs/icon/icon-finished.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort == null ? 10 : operations[i].sort
                })
              }
              //结束公文
              if (operations[i].operation == 'endProcess') {
                _this.barList.push({
                  name: '结束公文',
                  operation: 'endProcess',
                  icon: 'static/imgs/icon/icon-finished.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-finished-active.png',
                    inactive: 'static/imgs/icon/icon-finished.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort == null ? 10 : operations[i].sort
                })
              }
              //传阅
              if (operations[i].operation == 'circulate') {
                _this.barList.push({
                  name: '传阅',
                  operation: 'circulate',
                  icon: 'static/imgs/icon/icon-yy.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-yy-active.png',
                    inactive: 'static/imgs/icon/icon-yy.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }
              //分办管理
              if (operations[i].operation == 'fensongManagement') {
                _this.barList.push({
                  name: '分办管理',
                  operation: 'fensongManagement',
                  icon: 'static/imgs/icon/icon-handover.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-handover-active.png',
                    inactive: 'static/imgs/icon/icon-handover.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }
              //会签管理
              if (operations[i].operation == 'huiqianManagement') {
                _this.barList.push({
                  name: '会签管理',
                  operation: 'huiqianManagement',
                  icon: 'static/imgs/icon/icon-sign.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-sign-active.png',
                    inactive: 'static/imgs/icon/icon-sign.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }
              //退处室秘书
              if (operations[i].operation == 'tuisms' || operations[i].operation == 'tuichushiMs' || operations[i].operation == 'tgwms') {
                _this.barList.push({
                  name: operations[i].operationName,
                  operation: operations[i].operation,
                  icon: 'static/imgs/icon/icon-tuigwms.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-tuigwms-active.png',
                    inactive: 'static/imgs/icon/icon-tuigwms.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }
              //签发
              if (operations[i].operation == 'review_QianFa') {
                _this.barList.push({
                  name: '签发',
                  operation: 'review_QianFa',
                  icon: 'static/imgs/icon/icon-qianfa.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-qianfa-active.png',
                    inactive: 'static/imgs/icon/icon-qianfa.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }
              //作废
              if (operations[i].operation == 'cancelGw') {
                _this.barList.push({
                  name: '作废',
                  operation: 'cancelGw',
                  icon: 'static/imgs/icon/icon-invalid.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-invalid-active.png',
                    inactive: 'static/imgs/icon/icon-invalid.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }
              //作废
              if (operations[i].operation == 'zuofei') {
                _this.barList.push({
                  name: '作废',
                  operation: 'zuofei',
                  icon: 'static/imgs/icon/icon-invalid.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-invalid-active.png',
                    inactive: 'static/imgs/icon/icon-invalid.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }
              //同意
              if (operations[i].operation == 'review_TongYi') {
                _this.barList.push({
                  name: '同意',
                  operation: 'review_TongYi',
                  icon: 'static/imgs/icon/icon-agree.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-agree-active.png',
                    inactive: 'static/imgs/icon/icon-agree.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }
              //已阅
              if (operations[i].operation === 'jldyy' || operations[i].operation === 'jmsyy' || operations[i].operation === 'readalready') {
                _this.barList.push({
                  name: '已阅',
                  operation: operations[i].operation,
                  icon: 'static/imgs/icon/icon-yy.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-yy-active.png',
                    inactive: 'static/imgs/icon/icon-yy.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }
              //本单位会签完毕
              if (operations[i].operation == 'hqwb') {
                _this.barList.push({
                  name: '本单位会签完毕',
                  operation: 'hqwb',
                  icon: 'static/imgs/icon/icon-agree.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-agree-active.png',
                    inactive: 'static/imgs/icon/icon-agree.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }
              //清除意见
              if (operations[i].operation == 'deleteOpinion') {
                _this.barList.push({
                  name: operations[i].operationName,
                  operation: 'deleteOpinion',
                  icon: 'static/imgs/icon/icon-invalid.png',//供更多操作里的按钮使用，因其icon不能自定义，故给其单独的icon地址
                  iconTab: {
                    active: 'static/imgs/icon/icon-invalid-active.png',
                    inactive: 'static/imgs/icon/icon-invalid.png'
                  },
                  value: operations[i].operationName,
                  sort: operations[i].sort
                })
              }

            }
            // 功能按钮筛选
            if (this.util.isNotEmpty(this.buttonArr)) {
              let newBarList = []
              this.buttonArr.filter((b, index) => this.buttonArr.indexOf(b) === index).forEach((item) => {
                let arr = this.barList.filter(t => t.operation == item)
                if (arr != null && arr.length > 0) {
                  newBarList.push(arr[0])
                }
              })
              this.barList = newBarList
            } else {
              this.barList = []//如果获取到的按钮为空，则置空
            }
            //大于三个添加更多按钮,第四个按钮为更多操作
            if (_this.barList.length > 3) {
              _this.barList.sort((a, b) => a.sort - b.sort)
              var more = {
                name: '更多',
                operation: 'more',
                icon: 'static/imgs/icon/icon-more.png',
                iconTab: {
                  active: 'static/imgs/icon/icon-more-active.png',
                  inactive: 'static/imgs/icon/icon-more.png',
                },
                value: '更多操作',
              }
              _this.barList.splice(3, 0, more);
            }
          }
        } else {
          console.log("出错了: " + JSON.stringify(data));
        }
      })
      await this.showDeleteOpinionBtn()//判断是否显示清除意见按钮
    },

    //结束公文
    jieshuGongWen() {
      this.$httploading({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/completeWorkitem`),
        method: 'post',
        params: {
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          data: this.$http.adornData({
            swForm: this.detailObj1.detailObj,//详情
            wfmData: {
              'configId': this.paramObject.configId,
              'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
              'actDefId': this.paramObject.actDefId,//
              'proInstId': this.paramObject.proInstId,
              'actInstId': this.paramObject.actInstId,//
              'workitemId': this.paramObject.workitemId,
              'nextActivities': this.endGongWen
            },

          })
        }
      }).then(({data}) => {
        if (data.code == 200) {
          this.$toast('操作成功')
          uni.redirectTo({
            url: '/pages/caac/send/signList'
          })
        } else {
          _this.$toast(data.message + ' code:' + data.code)
        }
      })
    },

    //获取流转范围
    listNextActivities() {
      this.$http({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/listNextActivities?systemKey=` + this.userInfo.systemKey + `&systemFlag=` + this.userInfo.systemFlag),
        method: 'post',
        params: {
          //固定值
          'data': this.$http.adornData({
            wfmData: {
              'configId': this.paramObject.configId,
              'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
              'actDefId': this.paramObject.actDefId,//
              'actInstId': this.paramObject.actInstId,//
              'workitemId': this.paramObject.workitemId,
              'wfmInitPageType': 'running'
            }
          })
        }
      }).then(({data}) => {
        // console.log("结束公文参数data===>>>>: " + JSON.stringify(data));
        if (data.code == 200) {
          let nextActDefIds = data.data.nextActDefIds;
          let currentActDefId = this.paramObject.actDefId
          if (nextActDefIds) {
            for (var i = 0; i < nextActDefIds.length; i++) {
              if ("csgwmszz" == nextActDefIds[i].actDefId && currentActDefId.indexOf("scsldsp") > -1) {
                this.tuiGongWen.push(nextActDefIds[i])
              } else if ("sjzbsgzz" == nextActDefIds[i].actDefId && currentActDefId.indexOf("sjldsh") > -1) {
                this.tuiGongWen.push(nextActDefIds[i])
              } else if ("hqjsr" == nextActDefIds[i].actDefId && currentActDefId.indexOf("scsldhq") > -1) {
                this.tuiGongWen.push(nextActDefIds[i])
              }
              if (nextActDefIds[i].actType == 'end') {
                this.endGongWen.push(nextActDefIds[i])
              }
            }
          }
        } else {
          this.$toast(data.message + ' code:' + data.code)
        }

      })
    },
    //办结并退秘书
    endAndTuimsConfirm() {
      this.$dialog.confirm({
        confirmButtonColor: '#1989fa',
        title: '系统提示',
        message: '确认要结束公文吗?',
      }).then(() => {
        this.endAndTuims()//结束公文
      }).catch(() => {
        // on cancel
      });
    },
    //退公文秘书
    tuiGwmsConfirm(msType) {
      this.$dialog.confirm({
        title: '系统提示',
        message: '您确定要操作吗?',
      }).then(() => {
        if (msType == 'tuisms') {//退司秘书
          this.getSms()//获取司秘书
        } else if (msType == 'tgwms') {//退局秘书
          this.getJms()
        }
      }).catch(() => {

      });
    },

    //先获取局秘书
    getJms() {
      this.$http({
        url: this.$http.adornUrl(`/caac/wfm/MhjApplicationController/getJldMsRelate`),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
        })
      }).then(({data}) => {
        // console.log("获取这篇文的秘书-->data: " + JSON.stringify(data));
        if (data.code == 200) {
          if (this.util.isNotEmpty(data.data)) {
            data.data.forEach((item) => {
              if (this.userInfo.userId == item.ldId) {
                this.gwSercetJms = item
              }
            })
            this.sendWithoutSelectUserJuld()
          } else {
            this.$toast('该领导未配置秘书，需配置！')
          }
        }

      })
    },
    //获取司秘书
    getSms() {
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/doc/sjsw/siMs`),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
        })
      }).then(({data}) => {
        //{"code":200,"data":{"userId":"3961"},"message":null}
        if (data.code == 200) {
          if (this.util.isNotEmpty(data.data)) {
            data.data.forEach((item) => {
              this.gwSercetSms = item
            })
//            this.tuiGwmsSms()
            this.saveOpinionAndSendWithoutSelectUser()
          } else {
            this.$toast('该领导未配置秘书，需配置！')
          }
        }

      })
    },
    //退公文秘书操作
    sendWithoutSelectUserJuld() {
      this.$http({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/listNextActivities`),
        method: 'post',
        params: {
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          'data': this.$http.adornData({
            wfmData: {
              'configId': this.paramObject.configId,
              'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
              'actDefId': this.paramObject.actDefId,//
              'actInstId': this.paramObject.actInstId,//
              'workitemId': this.paramObject.workitemId,
              'wfmInitPageType': 'running'
            }
          })
        }
      }).then(({data}) => {
        if (data.code == 200) {
          let nextActDefIds = data.data.nextActDefIds
          if (nextActDefIds) {
            let nextActivity = nextActDefIds[0]
            nextActivity.participants = "user:" + this.gwSercetJms.msId
            let nextActivities = []
            nextActivities.push(nextActivity)
            //退公文秘书
            this.$httploading({
              url: this.$http.adornUrl(`/caac/wfm/ApplicationController/completeWorkitem`),
              method: 'post',
              params: {
                'systemKey': this.userInfo.systemKey,//固定值
                'systemFlag': this.userInfo.systemFlag,//固定值
                'data': this.$http.adornData({
                  'swForm': this.detailObj1.detailObj,//详情
                  'wfmData': {
                    'configId': this.paramObject.configId,
                    'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
                    'actDefId': this.paramObject.actDefId,//
                    'proInstId': this.paramObject.proInstId,
                    'actInstId': this.paramObject.actInstId,//
                    'workitemId': this.paramObject.workitemId,
                    'nextActivities': nextActivities
                  },
                })
              }
            }).then(({data}) => {
              if (data.code == 200) {
                if(data.data){
                  if(data.data.wfmData.isClosePage){
                    this.$toast('公文已退回给公文秘书！')
                  }else{
                    this.$toast(data.data.wfmData.message)
                  }
                  // 发送通知
                  let messageUserIds = this.gwSercetJms.msId;
                  let linkUrl = this.configUtil.baseUrl + this.configUtil.basePath + "/#/pages/caac/sjsw/index?proInstId=" + this.paramObject.proInstId;
                  this.lx.sendMessage(this.cache.get("appType"), messageUserIds,
                      this.detailObject.title, "司局收文", linkUrl);
                  uni.redirectTo({
                    url: '/pages/caac/send/signList'
                  })
                }else{
                  this.$toast("提交后返回数据为空，resultData=" + data.data)
                }
              } else {
                this.$toast(data.message + ' code:' + data.code)
              }
            })
          } else {
            this.$toast("操作失败，获取流程节点信息为空")
          }
        }

      })
    },
    //获取流转范围
    saveOpinionAndSendWithoutSelectUser() {
      this.$http({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/listNextActivities`),
        method: 'post',
        params: {
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          'data': this.$http.adornData({
            'wfmData': {
              'configId': this.paramObject.configId,
              'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
              'actDefId': this.paramObject.actDefId,//
              'actInstId': this.paramObject.actInstId,//
              'workitemId': this.paramObject.workitemId,
              'wfmInitPageType': 'running'
            }
          })
        }
      }).then(({data}) => {
        if (data.code == 200) {
          let nextActivity
          let nextActDefIds = data.data.nextActDefIds
          if (nextActDefIds) {
            for (let i = 0; i < nextActDefIds.length; i++) {
              if(nextActDefIds[i].actDefId == 'sms'){
                nextActivity = nextActDefIds[i]
                nextActivity.participants = "user:" + this.gwSercetSms.userId
                let nextActivities = []
                nextActivities.push(nextActivity)
                //退公文秘书
                this.$httploading({
                  url: this.$http.adornUrl(`/caac/wfm/ApplicationController/completeWorkitem`),
                  method: 'post',
                  params: {
                    'systemKey': this.userInfo.systemKey,//固定值
                    'systemFlag': this.userInfo.systemFlag,//固定值
                    'data': this.$http.adornData({
                      'swForm': this.detailObj1.detailObj,//详情
                      'wfmData': {
                        'configId': this.paramObject.configId,
                        'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
                        'actDefId': this.paramObject.actDefId,//
                        'proInstId': this.paramObject.proInstId,
                        'actInstId': this.paramObject.actInstId,//
                        'workitemId': this.paramObject.workitemId,
                        'nextActivities': nextActivities
                      },
                    })
                  }
                }).then(({data}) => {
                  if (data.code == 200) {
                    if(data.data){
                      if(data.data.wfmData.isClosePage){
                        this.$toast('公文已退回给公文秘书！')
                      }else{
                        this.$toast(data.data.wfmData.message)
                      }
                      // 发送通知
                      let messageUserIds = this.gwSercetSms.userId;
                      let linkUrl = this.configUtil.baseUrl + this.configUtil.basePath + "/#/pages/caac/sjsw/index?proInstId=" + this.paramObject.proInstId;
                      this.lx.sendMessage(this.cache.get("appType"), messageUserIds,
                          this.detailObject.title, "司局收文", linkUrl);
                      uni.redirectTo({
                        url: '/pages/caac/send/signList'
                      })
                    }else{
                      this.$toast("提交后返回数据为空，resultData=" + data.data)
                    }
                  } else {
                    this.$toast(data.message + ' code:' + data.code)
                  }
                })
              }
            }
          } else {
            this.$toast("操作失败，获取流程节点信息为空")
          }
        }
      })
    },
    //办结并退秘书
    endAndTuims() {
      this.$http({
        url: this.$http.adornUrl(`/caac/wfm/ApplicationController/completeWorkitem`),
        method: 'post',
        params: {
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          data: this.$http.adornData({
            fwForm: this.detailObj1.detailObj,//详情
            endProcessType: '1',
            wfmData: {
              'configId': this.paramObject.configId,
              'proDirId': this.paramObject.proDirId,//发文详情返回的proInstId
              'actDefId': this.paramObject.actDefId,//
              'proInstId': this.paramObject.proInstId,
              'actInstId': this.paramObject.actInstId,//
              'workitemId': this.paramObject.workitemId,
              'nextActivities': this.endGongWen
            },

          })
        }
      }).then(({data}) => {
        // console.log("结束公文data-->>: " + JSON.stringify(data));
        if (data.code == 200) {
          this.$toast("操作成功")
          uni.redirectTo({
            url: '/pages/caac/send/signList'
          })
        } else {
          this.$toast(data.message + ' code:' + data.code)
        }
      })
    },

    //获取已分办处室
    findfbdept(proInstId) {
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/component/fb/findfbdept`),
        method: 'get',
        params: {
          'systemKey': this.cache.get('userInfo').systemKey,
          'systemFlag': this.cache.get('userInfo').systemFlag,
          'proInstId': proInstId
        }
      }).then(({data}) => {
        //{"code":200,"data":{"runningNum":2,"deptIds":"001002005,001002006","depts":"司领导、局长办"},"message":null}
        if (data.code == 200) {
          this.otherDetail.fbDeptList = []
          data.data.deptIds.split(',').forEach((item, index) => {
            this.otherDetail.fbDeptList.push({"deptId": item, "deptName": data.data.depts.split('、')[index]})
          })
        }
      })
    },
    //传阅情况
    quertcirs(proInstId) {
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/component/workflow/circulatecontroller/quertcirs`),
        method: 'get',
        params: {
          'systemKey': this.cache.get('userInfo').systemKey,
          'systemFlag': this.cache.get('userInfo').systemFlag,
          'proInstId': proInstId,
        }
      }).then(({data}) => {
        if (data.code == 200) {
          this.dataList.quertcirsProcess = data.data
          const res = new Map()
          this.otherDetail.chuanYueList = data.data.filter((t) => !res.has(t['receiverDeptName']) && res.set(t['receiverDeptName'], 1))
        }
      })
    },

    //获取已发送部门
    getfasongdepts(proInstId) {
      this.$http({
        url: this.$http.adornUrl(`/caac/oa/doc/sjsw/getfasongdepts`),
        method: 'get',
        params: {
          'systemKey': this.cache.get('userInfo').systemKey,
          'systemFlag': this.cache.get('userInfo').systemFlag,
          'proInstId': proInstId,
        },
      }).then(({data}) => {
        if (data.code == 200) {
          if (data.code == 200) {
            this.otherDetail.fsDeptList = data.data
          }
        }
      })
    },
    //判断是否显示清除意见按钮
    async showDeleteOpinionBtn(){
      await this.$http({
        url: this.$http.adornUrl(`/caac/oa/component/approval/findmyopinion`),
        method: 'get',
        params: this.$http.adornParams({
          'systemKey': this.userInfo.systemKey,//固定值
          'systemFlag': this.userInfo.systemFlag,//固定值
          'proInstId':this.proInstId,
          'workItemId':this.paramObject.workitemId,
          'approver':this.userInfo.userId
        })
      }).then(({data}) => {
        if (data.code == 200) {
          if (this.util.isNotEmpty(data.data)) {
            this.opinionId = data.data.id //要删除的意见id
          }else{
            this.opinionId = ''
            //如果意见为null,则不显示清除意见按钮
            this.barList = this.barList.filter(t => t.operation != 'deleteOpinion' && t.operation != 'more')
            //大于三个添加更多按钮,第四个按钮为更多操作
            if (this.barList.length > 3) {
              this.barList.sort((a, b) => a.sort - b.sort)
              let more = {
                name: '更多',
                operation: 'more',
                icon: 'static/imgs/icon/icon-more.png',
                iconTab: {
                  active: 'static/imgs/icon/icon-more-active.png',
                  inactive: 'static/imgs/icon/icon-more.png',
                },
                value: '更多操作',
              }
              this.barList.splice(3, 0, more);
            }
          }
        } else {
          console.log(data.message)
        }

      })

    },
    //清除意见
    deleteOpinionConfirm(){
      this.$dialog.confirm({
        title: '系统提示',
        message: '您确定要操作吗?',
      }).then(() => {
        this.deleteOpinion()//删除意见
      }).catch(() => {
      });
    },
    //删除意见
    deleteOpinion() {
      if (this.util.isNotEmpty(this.opinionId)) {
        this.$http({
          url: this.$http.adornUrl(`/caac/oa/component/approval`),
          method: 'delete',
          params: this.$http.adornParams({
            'systemKey': this.userInfo.systemKey,//固定值
            'systemFlag': this.userInfo.systemFlag,//固定值
            'opinionId': this.opinionId
          })
        }).then(({data}) => {
          if (data.code == 200) {
            this.$toast("删除意见成功")
            this.refreshBtnGroup('')
          } else {
            this.$toast(data.message)
          }
        })
      }else{
        this.$toast('当前没有可删除的意见!')
      }
    }



  },
};
</script>

<style scoped>

</style>
